Base class for clustering algorithm.
BaseClusterer(ABC, Base)
Abstract base class for clustering algorithms.
This class defines the core interface for clustering models. It enforces
the implementation of the fit
and predict
methods in all derived classes,
and provides a default implementation for fit_predict
and get_params
.
Function fit(...)
def fit(self, X: npt.NDArray, verbose: bool = True) -> BaseClusterer
Fit the model to the training data. This abstract method must be implemented by subclasses.
Parameters:
- X:
npt.NDArray
Input data used for training the model. - verbose:
bool
, default=True Flag to enable or disable detailed output during training.
Returns:
- self: Instance of the class that implements this method.
Implementation:
Function predict(...)
def predict(self, X: npt.NDArray) -> Optional[npt.NDArray]
Generate predictions based on the input data. This abstract method must be implemented by subclasses.
Parameters:
- X:
npt.NDArray
Input data for which predictions will be generated.
Returns:
- predictions:
Optional[npt.NDArray]
Predicted cluster labels for each input sample, orNone
if prediction is not possible.
Implementation:
Function fit_predict(...)
def fit_predict(self, X: npt.NDArray, verbose: bool = True) -> Optional[npt.NDArray]
Convenience method that combines fit
and predict
in a single call.
Parameters:
- X:
npt.NDArray
Input data for which predictions will be generated. - verbose:
bool
, default=True Flag to enable or disable detailed output during training.
Returns:
- predictions:
Optional[npt.NDArray]
Predicted cluster labels for each input sample, orNone
if prediction is not possible.